import httplib
import urllib
from unittest import TestCase



class HttpClientTest(TestCase):

    def test_now(self):
        return

    def test_build(self):

        host = 'localhost'
        port = 8000
        url = '/tactic/nuke/build'

        params = {
            'name': 'name',
            'basepath': 'basepath',
            'master_basepath': 'master_basepath',
            'master_nukepath': 'master_nukepath',
        }
        body = urllib.urlencode(params)

        headers = {
            "Content-type": "application/x-www-form-urlencoded",
            "Accept": "text/plain"
        }

        print body

        httpClient = None
        try:
            httpClient = httplib.HTTPConnection(host, port)
            httpClient.request(method='POST', url=url, body=body, headers=headers)

            response = httpClient.getresponse()
            print '[response.status]:' + str(response.status)
            print '[response.reason]:' + str(response.reason)
            print '[response.read]:' + str(response.read())
            print '[response.headers]:' + str(response.getheaders())

        except Exception, e:
            print 123
            print e

        finally:
            if httpClient:
                httpClient.close()

        #self.fail()